package com.d0318;

public class Tickets {
        private int tickets=20;
        public void one(){
            synchronized(this) {
                System.out.println(Thread.currentThread().getName());
                tickets--;
            }
        }
        public void two(){
            System.out.println(Thread.currentThread().getName());
        }
        public void three(){
            System.out.println(Thread.currentThread().getName());
        }

        public static void main(String[] args) {
            Tickets ticket=new Tickets();
            new Thread(()->ticket.one()).start();
            new Thread(()->ticket.two()).start();
            new Thread(()->ticket.three()).start();
        }
    }

